<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>质检</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
    <script src="../../../res/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../../res/js/jquery-3.4.1.min.js"></script>
    <script src="../../../res/js/util.js"></script>
</head>

<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>质检入库</legend>
</fieldset>

<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">计划名称</label>
        <div class="layui-input-block">
            <input type="text" id="planName" disabled="" class="layui-input layui-disabled">
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">药品信息</label>
            <div class="layui-input-block">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>药品名称</th>
                        <th>药品数量</th>
                        <th>制造时间</th>
                    </tr>
                    </thead>
                    <tbody id="tbody">
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" id="remark" maxlength="1024" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" id="dd" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn"  lay-event="getData">一键全部入库</button>
        <!--<button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>-->
    </div>
</script>

<script>

    var form = null;
    var layer = null;
    let array = new Array();
    let s = 0;
    layui.use(['form', 'layer'], function () {
        form = layui.form
            , layer = layui.layer

        form.on('submit(demo1)', function (data) {
            s=1;
            if(s==1){
                let url = "../../../manufacturePlan/quality";
                $.post(url,{jsonStr:JSON.stringify(array),remark:$("#remark").val()},function (obj) {
                    layer.msg(obj.message);
                    if(obj.status==20){
                        parent.closeOpen(obj.message)
                    }else{
                        s=0;
                    }
                },'json')
            }

            return false;
        });
    })


    $(function () {

        let planId = window.localStorage.getItem("planId");
        window.localStorage.removeItem("planId");
        let url =  '../../../manufacturePlan/queryByPlanId';
        $.get(url, {planId:planId},function (obj) {
            array = obj;
            $("#planName").val(obj[0].planName)
            $.each(obj,function (index,item) {
                console.info(item.planName)
                $("#tbody").append('<tr><td>'+item.drugName+'</td><td>'+item.mpTask+'</td><td>'+item.mpTime+'</td></tr>')
            })

        },'json')
    })








</script>
</body>
</html>